package com.graphics;

import javax.swing.*;
import java.awt.*;

public class Test_1 extends JFrame {
    private MyPanel mp=null;//画板
    public static void main(String[] args) {
        new Test_1();
    }
    public Test_1(){//初始化画板
        mp=new MyPanel();
        this.add(mp);//添加画板
        this.setSize(1080,680);//设置画板大小
        this.setVisible(true);//画板可视化
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//x退出程序
    }
}

class MyPanel extends JPanel{
    @Override
    public void paint(Graphics g) {//画笔
        super.paint(g);
        g.fillRect(0,0,1080,680);
        //画笔画东西
        g.setColor(Color.green);
        g.fillOval(300,300,50,50);
        ///添加图片
        Image image=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/gold.png"));
        g.drawImage(image,500,350,200,200,this);
    }
}